package com.elitesland.metadata.service.impl;

import com.elitesland.metadata.convert.MetaCatDefConvert;
import com.elitesland.metadata.repo.MetaCatDefRepo;
import com.elitesland.metadata.service.MetaCatDefService;
import com.elitesland.metadata.vo.MetaCatDefVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * <pre>作用说明</pre>
 *
 * @author mir
 * @date 11/29/2020 1:13 AM
 */
@Service
public class MetaCatDefServiceImpl implements MetaCatDefService {

    private MetaCatDefRepo metaCatDefRepo;

    @Autowired
    public void setMetaCatDefRepo(MetaCatDefRepo metaCatDefRepo) {
        this.metaCatDefRepo = metaCatDefRepo;
    }

    @Override
    public List<MetaCatDefVO> listByTableCode(String code) {
        return metaCatDefRepo.findAllByTableCodeOrderBySortNo(code)
                .stream().map(MetaCatDefConvert.INSTANCE::doToVO)
                .collect(Collectors.toList());
    }
}
